import matplotlib.pyplot as plt
from matplotlib import dates, ticker
import matplotlib as mpl


import datetime
import time
import sqlite3
import matplotlib.patches as patches
import datetime
from  iplot.bar import Maxdensity  
from iplot import iplothelper
plt.rcParams['font.sans-serif'] = ['SimHei']  # 用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False  # 用来正常显示负号


if __name__ == '__main__':
    
    
    
    fig, ax = plt.subplots(figsize=(15, 9))

    start_date = '2017-01-24'
    end_date  = '2017-01-28'

    rs_date = '2017-01-24'
    re_date = '2017-01-26'

    start_timestamp =  iplothelper.dateStr2timestamp(start_date,'%Y-%m-%d')
    end_timestamp = iplothelper.dateStr2timestamp(end_date,'%Y-%m-%d')
    rs_stamp =  iplothelper.dateStr2timestamp(rs_date,'%Y-%m-%d')
    re_stamp =  iplothelper.dateStr2timestamp(re_date,'%Y-%m-%d')

    tracker = Maxdensity(ax, fig,start_timestamp,end_timestamp,rs_stamp,re_stamp)

    # 绘制日期分割线
    plt.axvline(x=tracker.division, alpha=0.5)
    for i in tracker.denstity_list[-2:-1]:
        plt.axhline(y=i)
    plt.show()
